<html>
<head><meta charset="utf-8"><title>SIMD expert needed · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html">SIMD expert needed</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212165420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212165420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212165420">(Oct 03 2020 at 10:43)</a>:</h4>
<p>Could someone with SIMD knowledge please take a look at <a href="https://github.com/rust-lang/rust/issues/77477">https://github.com/rust-lang/rust/issues/77477</a>? Thanks :)</p>



<a name="212169764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212169764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212169764">(Oct 03 2020 at 12:39)</a>:</h4>
<p>Maybe <span class="user-mention" data-user-id="224471">@Lokathor</span> ?</p>



<a name="212174954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212174954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212174954">(Oct 03 2020 at 14:30)</a>:</h4>
<p>I saw that for a moment last night and I was actually confused on how the llvm intrinsics are supposed to work here.</p>
<p>Usually I use the vendor intrinsics when I do simd stuff.</p>



<a name="212214575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212214575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212214575">(Oct 04 2020 at 09:22)</a>:</h4>
<p>so how do those work, does rustc do static bounds checking there?</p>



<a name="212214689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212214689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212214689">(Oct 04 2020 at 09:26)</a>:</h4>
<p>Using llvm intrinsics directly can easily be unsound. There are no correctness checks, as rustc doesn't know which llvm intrinsics exist.</p>



<a name="212214704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212214704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212214704">(Oct 04 2020 at 09:26)</a>:</h4>
<p>so "using vendor intrinsis" is an alias for "using llvm intrinsics directly"?</p>



<a name="212214761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212214761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212214761">(Oct 04 2020 at 09:28)</a>:</h4>
<p>The intrinsics in <code>core::arch</code> are wrappers around llvm intrinsics that handle out-of-bound indexes. Often by masking the index.</p>



<a name="212214779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212214779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212214779">(Oct 04 2020 at 09:29)</a>:</h4>
<p><a href="https://github.com/rust-lang/stdarch/blob/027680f3ad857fb1ce2994b1e088f0655d9b3a58/crates/core_arch/src/macros.rs#L7">https://github.com/rust-lang/stdarch/blob/027680f3ad857fb1ce2994b1e088f0655d9b3a58/crates/core_arch/src/macros.rs#L7</a></p>



<a name="212215392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212215392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212215392">(Oct 04 2020 at 09:47)</a>:</h4>
<p>oO</p>



<a name="212215440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212215440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212215440">(Oct 04 2020 at 09:48)</a>:</h4>
<p>and the underlying intrinsic then is <code>simd_extract</code>/<code>simd_insert</code>?</p>



<a name="212215925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212215925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212215925">(Oct 04 2020 at 10:01)</a>:</h4>
<p>In this case yes, there are also vendor intrinsics that directly use llvm intrinsics.</p>



<a name="212217915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212217915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212217915">(Oct 04 2020 at 10:55)</a>:</h4>
<p>so the vendor intrinsics are not really intrinsics in a rustc or LLVM sense? this is all very confusing^^</p>



<a name="212218410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212218410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212218410">(Oct 04 2020 at 11:10)</a>:</h4>
<p>Even for C compilers vendor intrinsics may not even be implemented as compiler intrinsics. This includes functions like <code>_mm_cvtsi64_m64</code> (implemented as <code>(__m64)__i</code> in clang), <code>_mm256_add_pd</code> (implemented as <code>(__m256d)((__v4df)__a+(__v4df)__b)</code> in clang), ... In addition every vendor intrinsic for clang that does actually use a real compiler intrinsic is a wrapper around a <code>__builtin_*</code> compiler intrinsic.</p>



<a name="212218414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212218414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212218414">(Oct 04 2020 at 11:11)</a>:</h4>
<p>Take a look at for example <code>/usr/include/clang/7.0.1/include/avxintrin.h</code>.</p>



<a name="212219322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212219322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212219322">(Oct 04 2020 at 11:37)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> so the answer to my question is "yes"?</p>



<a name="212219326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212219326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212219326">(Oct 04 2020 at 11:37)</a>:</h4>
<p>Correct</p>



<a name="212219369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SIMD%20expert%20needed/near/212219369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SIMD.20expert.20needed.html#212219369">(Oct 04 2020 at 11:38)</a>:</h4>
<p>no wonder I am confused then :D terminology seems to be somewhat overloaded</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>